<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>案例5</title>
    <link rel="stylesheet" href="../css/index.css">
    <style>
        .mydiv {
            margin: 20px;
            width: 200px;
            height: 200px;
            background-color: #000;
        }
    </style>
</head>

<body>
    <div class="content a-c">
        属性名：<input id="elme" type="text"><br> 属性值：
        <input id="val" type="text"><br>
        <button onclick="use()">使用</button>
        <button onclick="c.style = mystyle">重置</button>
        <div class="mydiv">

        </div>
    </div>

    <script>
        let a = document.querySelector('#elme')
        let b = document.querySelector('#val')
        let c = document.querySelector('.mydiv')
        let mystyle = c.style

        function use() {
            c.style[a.value] = b.value
        }
    </script>

</body>

</html>